package com.shop2cn.iapi.agentproducts.testcase;

import java.util.Arrays;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.shop2cn.iapi.agentproducts.parameter.UploadImageByUrlBean;
import com.shop2cn.iapi.agentproducts.service.UploadImageByUrlCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
/**
*通过外部图片链接上传图片Test
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_UploadImageByUrl{
	private static UploadImageByUrlBean uploadimagebyurlBean;
	private static UploadImageByUrlCall uploadimagebyurlCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("通过外部图片链接上传图片Test");
	}

	@Before
	public void caseUp() {
		uploadimagebyurlBean=new UploadImageByUrlBean();
		uploadimagebyurlCall=new UploadImageByUrlCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(uploadimagebyurlCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_UploadImageByUrl_001() {
		Logger.start(true,"一张图片，成功");
		try {
			uploadimagebyurlBean.setUserId(500743492);
			uploadimagebyurlBean.setImageUrlList(Arrays.asList("http://dockerci.better.ymatou.com/static/8f20f4e1/images/32x32/health-80plus.png"));
			uploadimagebyurlCall.setData(uploadimagebyurlBean);
			uploadimagebyurlCall.callService();			
			Logger.verifyEquals("200", uploadimagebyurlCall.getString("code"), "验证code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_UploadImageByUrl_002() {
		Logger.start(true,"多张图片，成功");
		try {
			uploadimagebyurlBean.setUserId(500743492);
			uploadimagebyurlBean.setImageUrlList(Arrays.asList("http://dockerci.better.ymatou.com/static/8f20f4e1/images/32x32/health-80plus.png","http://dockerci.better.ymatou.com/static/8f20f4e1/images/48x48/blue_anime.gif"));
			uploadimagebyurlCall.setData(uploadimagebyurlBean);
			uploadimagebyurlCall.callService();			
			Logger.verifyEquals("200", uploadimagebyurlCall.getString("code"), "验证code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_UploadImageByUrl_003() {
		Logger.start(true,"不输入userId，成功");
		try {
			uploadimagebyurlBean.setImageUrlList(Arrays.asList("http://dockerci.better.ymatou.com/static/8f20f4e1/images/32x32/health-80plus.png","http://dockerci.better.ymatou.com/static/8f20f4e1/images/48x48/blue_anime.gif"));
			uploadimagebyurlCall.setData(uploadimagebyurlBean);
			uploadimagebyurlCall.callService();			
			Logger.verifyEquals("400", uploadimagebyurlCall.getString("code"), "验证code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_UploadImageByUrl_004() {
		Logger.start(true,"不输入图片链接，成功");
		try {
			uploadimagebyurlBean.setUserId(500743492);
			uploadimagebyurlCall.setData(uploadimagebyurlBean);
			uploadimagebyurlCall.callService();			
			Logger.verifyEquals("400", uploadimagebyurlCall.getString("code"), "验证code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_UploadImageByUrl_005() {
		Logger.start(true,"图片链接错误，转换失败");
		try {
			uploadimagebyurlBean.setUserId(500743492);
			uploadimagebyurlBean.setImageUrlList(Arrays.asList("http://dockerci.better.ymatou.com/666.png"));
			uploadimagebyurlCall.setData(uploadimagebyurlBean);
			uploadimagebyurlCall.callService();			
			Logger.verifyEquals("500", uploadimagebyurlCall.getString("code"), "验证code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	
}